#ifndef ENTITYEDITOR_H
#define ENTITYEDITOR_H

#include <head/g_pch.h>
#include "m_fhs.h"

namespace Ui {
class EntityEditor;
}

class EntityEditor : public QDialog
{
    Q_OBJECT

public:
    explicit EntityEditor(QWidget *parent,
                          const QSqlDatabase &db_);
    ~EntityEditor();

    void updateListView();
    void updateLabels();
    QVariant fetchItem(const QString &sql);
    QStringList fetchItems(const QString &sql);
    bool addItem(const QString &detail);
    bool updateItem(const QString &detail,int id);

private slots:
    void on_listView_doubleClicked(const QModelIndex &index);
    void on_labels_currentTextChanged(const QString &label);
    void on_btn_submit_clicked();

private:
    Ui::EntityEditor *ui;

    bool isOperator;
    QString table;
    QStringListModel *model;

    QSqlDatabase db;
    QString selectEntry,selectLabel;
};

#endif // ENTITYEDITOR_H
